﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WinForm.Validation
{
    public class NotBlankFieldValidator : IValidator
    {
        private Control _owner;
        private string _message;

        public NotBlankFieldValidator(Control control)
        {
            this._owner = control;
        }

        public bool Validate()
        {
            bool result = true;
            this._message = String.Empty;
            if (this._owner.CausesValidation)
            {
                if (String.IsNullOrEmpty(this._owner.Text))
                {
                    result = false;
                    this._message = "必填项";
                }
            }
            return result;
        }

        public string Message
        {
            get { return this._message; }
        }

        public Control Owner
        {
            get { return this._owner; }
        }
    }
}
